<?php
namespace app\admin\controller;
use think\Controller;
use think\Loader;
class Index extends Controller
{
    //后台首页
    public function index()
    {
        return $this->fetch();
    }

    //后台 main
    public function main(){
        $admin = session('Admin_user_lvtuan');
        if(empty($admin)){
            $this->redirect(config('tempredirect_url'));

        }else{
            $invoking     = Loader::model('Adport','service');
            $data         = $invoking->main_list();
            $data         = $data?$data:null;
            $this->assign('list', $data);
        }
        return $this->fetch();
    }

    //后台
    public function home(){
        $invoking     = Loader::model('Other','service');
        $data         = $invoking->indexCount();
        $data_list    = $invoking->indexList();
        $this->assign('data', $data);
        $this->assign('data_list', $data_list);
        $this->assign('betime', date('Y-m'));
        return $this->fetch();
    }

    // 后台管理员session
    public function adminSession() {
        $admin = session('Admin_user_lvtuan');
        //正常请求
        if(empty($admin)){
            $this->error('没有权限操作');
        }
        $url = $_SERVER['HTTP_HOST'];
        $url = $url . $_SERVER['REQUEST_URI'];
        $wyrolelist_hplxtws = session("wyrolelist_lvtuan");
        if ($wyrolelist_hplxtws == null) {
            $this->error('没有权限操作');
        }
        $result = CheckAuthority($url);

        if (!$result) {
            $this->error('没有权限操作');
        }
    }
}
